﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Data;

namespace ReklamaWPF.Grids
{
    /// <summary>
    /// Interaction logic for Pivot2Grid.xaml
    /// </summary>
    public partial class Pivot2Grid : UserControl
    {
        public Pivot2Grid()
        {
            InitializeComponent();
            datePicker1.DisplayDate = DateTime.Now;
            datePicker1.Text = DateTime.Now.ToShortDateString();
        }

        private void datePicker1_SelectedDateChanged(object sender, SelectionChangedEventArgs e)
        {
            DataBase db = new DataBase("192.168.100.100\\SQLEXPRESS", "sa", "tornado", "PASystem");
            DataTable tb = db.getTable("select * from AdvertisingData left join Clips on Clip_id=Clips.id left join Blocks on [Time]>[Time_from] and [Time]<[Time_to] where Date='" + datePicker1.Text + "'");

            pivotGridControl2.DataSource = tb;
        }
    }
}
